import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import console from '@/views/console'
import aiChange from '@/views/aichange/index.vue'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'home',
      component: () => import('@/views/home/index')
    }]
  },
  {
    path: '/console',
    component: aiChange,
    redirect: '/console/console/index',
    name: 'Console',
    meta: { title: '账户管理', icon: 'el-icon-s-help' },
    children: [
      {
        path: '/console/console/index',
        name: 'consoleIndex',
        component: () => import('@/views/console/console'),
        meta: { title: '账户管理', icon: 'bank-card',active_menu:'/aichange/deepRewrite' }
      },
      {
        path: '/console/example/index',
        name: 'exampleIndex',
        component: () => import('@/views/console/example/example'),
        meta: { title: '站点管理', icon: 'set-up',active_menu:'/aichange/deepRewrite' }
      },
      {
        path: '/console/example/secureindex',
        name: 'secure',
        component: () => import('@/views/console/example/secureindex'),
        meta: { title: '发布接口配置', icon: 'connection',active_menu:'/aichange/deepRewrite' }
      },{
        path: '/console/example/secure',
        name: 'secure',
        component: () => import('@/views/console/example/secure'),
        meta: { title: '任务目标管理', icon: 'orange',active_menu:'/aichange/deepRewrite' }
      },{
        path: '/console/example/lexicon',
        name: 'lexicon',
        hidden: true,
        component: () => import('@/views/console/example/lexicon'),
        meta: { title: '私有词库管理',active_menu:'/aichange/deepRewrite' }
      },
      {
        path: '/console/example/mirror-image',
        name: 'mirror-image',
        component: () => import('@/views/console/example/mirror-image'),
        meta: { title: '功能细节设置', icon: 'share' }
       },
        // {
      //   path: '/console/account/recharge',
      //   name: 'recharge',
      //   component: () => import('@/views/console/account/recharge'),
      //   meta: { title: '手动运行测试', icon: 'video-play' }
      // },
      {
        path: '/console/account/withdrawal',
        name: 'recharge',
        component: () => import('@/views/console/account/withdrawal'),
        meta: { title: '文章暂存库', icon: 'coin',active_menu:'/aichange/deepRewrite' }
      },
      // {
      //   path: '/console/account/iframe',
      //   name: 'iframe',
      //   component: () => import('@/views/console/example/iframe'),
      //   meta: { title: '提取', icon: 'coin' }
      // }
    ]
  },
  {
    path: '/aichange',
    component: console,
    redirect: '/aichange/deepRewrite',
    name: 'AiChange',
    meta: { title: '深度功能', icon: 'el-icon-s-help' },
    children: [

      // {
      //   path: '/aichange/aiChange',
      //   name: 'aiChange',
      //   component: () => import('@/views/aichange/aiChange.vue'),
      //   meta: { title: '同义词伪原创', icon: 's-finance' }
      // },
      // {
      //   path: '/aichange/aiChange/originalAi',
      //   name: 'originalAi',
      //   component: () => import('@/views/aichange/aiChanges/originaleAi.vue'),
      //   meta: { title: '智能AI伪原创', icon: 's-operation' }
      // },
      {
        path: '/aichange/deepRewrite',
        name: 'deepRewrite',
        component: () => import('@/views/aichange/aiChanges/deepRewrite'),
        meta: { title: '深度功能', icon: 'data-analysis',active_menu:'/aichange/deepRewrite' }
      },
      {
        path: '/aichange/articleDetail',
        name: 'articleDetail',
        component: () => import('@/views/aichange/aiChanges/articleDetail'),
        meta: { title: '编辑文章', icon: 'notebook-2',active_menu:'/aichange/deepRewrite' }
      },
      // {
      //   path: '/aichange/aiChange/deepOriginalTitle',
      //   name: 'deepOriginalTitle',
      //   component: () => import('@/views/aichange/aiChanges/deepOriginalTitle'),
      //   meta: { title: '深度原创标题', icon: 'mobile',active_menu:'/aichange/deepRewrite' }
      // },
      // {
      //   path: '/aichange/aiChange/detectionOriginal',
      //   name: 'detectionOriginal',
      //   component: () => import('@/views/aichange/aiChanges/detectionOriginal.vue'),
      //   meta: { title: '文章原创检测', icon: 'share' }
      // }
    ]
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
